import React, { useEffect } from 'react'
import { NavigationStackScreenComponent } from 'react-navigation-stack'
import { ActivityIndicator } from 'react-native'
import { useStoreIsReady } from 'utils/store'
import { useAuthorization } from 'services/authorization'
const AuthLoadingScreen: NavigationStackScreenComponent = props => {
	const storeIsReady = useStoreIsReady()
	const auth = useAuthorization()

	useEffect(() => {
		if (!storeIsReady) return

		props.navigation.navigate(auth.state.isLogin ? 'AppHome' : 'SignIn')
	})
	return <ActivityIndicator />
}
export default AuthLoadingScreen as any
